<script setup lang="ts">
interface Props {
  rowData: Object;
  visibleEdit?: boolean;
  visibleDelete?: boolean;
  deleteTip?: string;
  subTip?: string;
}
interface Emits {
  (e: 'clickEdit', rowData: Object): void;
  (e: 'clickDelete', rowData: Object): void;
}
const props = withDefaults(defineProps<Props>(), {
  visibleEdit: true,
  visibleDelete: true
});
const emit = defineEmits<Emits>();
const clickEdit = () => {
  emit('clickEdit', props.rowData);
};
const clickDelete = () => {
  emit('clickDelete', props.rowData);
};
</script>

<template>
  <n-space>
    <n-space>
      <n-button v-if="visibleEdit" type="primary" text ghost @click="clickEdit">编辑</n-button>
      <n-popconfirm v-if="visibleDelete"  @positive-click="clickDelete">
        <template #trigger>
        <n-button text type="error">删除</n-button>
        </template>
        <span v-if="deleteTip">
          您确定要删除【{{deleteTip}}】吗？
          <span v-if="subTip">{{subTip}}</span>
        </span>
        <span v-else>
          确定删除当前数据吗？
        </span>
      </n-popconfirm>
      <slot></slot>
    </n-space>
  </n-space>
</template>

<style scoped>

</style>
